﻿<?php
	error_reporting(E_ALL^E_NOTICE);
	require_once ('./config/config.php'); 
	require_once ('./class/email.class.php'); 
	require_once ('./class/tools.class.php');
	date_default_timezone_set("PRC");
	session_start();
	if(empty($_SESSION['user'])){
		echo "<script>location='./login.php';</script>";
		exit();
	}else{
		if($_GET['oper']=="logout"){
			unset($_SESSION['user']);
			echo "<script>location='./index.php';</script>";
			exit();
		}
	}
?>
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>某高校图书共享网站</title>
		<meta name="description" content="A responsive web app template with common components like profile, list, tabs, menu views. Made for Codrops exclusively.">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="stylesheet" href="./assets/output.css">
		<link rel="stylesheet" href="./assets/node_modules/tippy.js/dist/themes/light.css">
		<link rel="stylesheet" href="./layui/css/layui.css">
		<script src="./layui/js/layui.js" v="layui" e="layui"></script>
		<style>
			.layui-input{
				width:90%;
				float:left;
			}
			.layui-btn{
				width:10%;
				float:left;
			}
		</style>
	</head>
	<body class="bg-grey-lighter font-sans antialiased">
		<!--[if lt IE 7]>
			<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
		<![endif]-->
		<div class="bg-indigo-darker text-center p-4 px-6 flex items-center">
			<div class="hidden lg:block lg:w-1/4 xl:w-1/5 pr-8">
				<font color="#ffffff"><h1>某高校图书共享网站</h1></font>
			</div>
		</div>
		<!-- Main -->
		<div class="flex">
			<!-- Content -->
			<div class="flex flex-1 flex-col md:px-6 pt-10" id="content">
				<!-- Title -->
				<div class="px-6 md:px-0 flex justify-between items-center -order-1">
					<div>
						<h2 class="font-normal"><a href="./index.php">返回首页</a></h2>
					</div>
					<p>欢迎您，<?php echo $_SESSION['user'];?> ! | <a href="./my.php">个人中心</a> | <a href="?oper=logout">注销</a></p>
				</div>
				<!-- Desktop Stats -->
				<div align="center">
					<br /><br />
					<h2>
						<form action="./search.php" method="get">
							<input type="text" class="layui-input" name="searchKey" value="<?php if($_GET['searchKey']){echo $_GET['searchKey'];}?>" placeholder="请输入要搜索的图书" float="left">
							<input type="submit" class="layui-btn" value="搜索" float="left">
						</form>
					</h2>
				</div>
				<!-- Filter -->
				<div class="px-6 md:px-0 flex items-baseline justify-between border-b-2 border-grey-light mt-6 order-0 lg:order-1">
					<h4 class="hidden md:inline-block text-grey-dark font-normal">搜索的图书</h4>
				</div>
				<!-- Library -->
				<div class="hidden px-2 pt-2 md:px-0 flex-wrap order-2 pb-8 js-tab-pane active" id="section-library">
						<?php
							if($_GET['searchKey']){
								$searchKey=$_GET['searchKey'];
								$book=mysqli_query($con,"select * from book_sharing where book_name like'%".$searchKey."%' and inspect='1' order by bid asc");
								while($bookRs=mysqli_fetch_array($book)){ ?>
								<div class='flex flex-row sm:flex-col items-center sm:items-start w-full xs:w-1/2 sm:w-1/3 md:w-1/5 p-4 js-book'>
									<a href="./more.php?bid=<?php echo $bookRs['bid'];?>" target="_block">
										<div class="w-1/3 sm:w-full shadow-md transition-normal hover:brighter hover:translate-y-1 hover:shadow-lg hover:border-indigo">
											<?php echo $bookRs['book_cover'];?>
										</div>
										<div class="ml-3 sm:ml-0 w-2/3 sm:w-full">
											<p class="text-sm my-2 font-medium sm:font-normal"><?php echo $bookRs['book_name'];?></p>
											<label for="" class="hidden sm:inline-block rounded-full libre-bg-grey text-white px-2 py-1/2 text-xs">借阅状态:<?php if($bookRs['state']=="0"){echo "未借出";}elseif($bookRs['state']=="1"){echo "借阅协调中";}elseif($bookRs['state']=="2"){echo "已借出";}elseif($bookRs['state']=="4"){echo "借阅异常";}else{echo "系统异常";} ?></label>
											<label for="" class="hidden sm:inline-block rounded-full libre-bg-grey text-white px-2 py-1/2 text-xs">借阅押金:<?php echo $bookRs['book_price'];?> HY币</label>
										</div>
									</a>
								</div>
							<?php		
								}
							}else{
								echo "<br />暂未开始搜索";
							}
						?>
				</div>
			</div>
		</div>
		<script src="./assets/bundle.js" async defer></script>
</body>
</html>